package com.estar.integaration.Reader;

import com.alibaba.excel.EasyExcel;
import com.estar.integaration.Reader.Listener.DueReceiptDetailListener;
import com.estar.integaration.Reader.Listener.PurchaseOrderDetailListener;
import com.estar.integaration.entity.paymentPlanEntity.DueReceiptDetail;
import com.estar.integaration.entity.paymentPlanEntity.PurchaseOrderDetail;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: YJL
 * Date: 2022/2/17 15:43
 * 采购订单执行明细.xlsx
 **/
public class PurchaseOrderDetailReader {

  List<String> addresses = new ArrayList<>();
  List<PurchaseOrderDetail> purchaseOrderDetailList = new ArrayList<>();

  public PurchaseOrderDetailReader(List<String> addresses) {
    this.addresses = addresses;
  }

  public List<PurchaseOrderDetail> readPurchaseODR(){
    for(String address : addresses){
      List<PurchaseOrderDetail> tmpList = new ArrayList<>();

      EasyExcel.read(address,PurchaseOrderDetail.class,new PurchaseOrderDetailListener(tmpList))
          .sheet(0)
          .headRowNumber(3)
          .doRead();
      purchaseOrderDetailList.addAll(tmpList);
    }
    return purchaseOrderDetailList;
  }
}
